import random
from datetime import datetime, timedelta
from faker import Faker
from api.base_api import BasePrimeSpApi

fake = Faker(locale='zh_CN')


class Prime_DirectPledgeLoan_Add(BasePrimeSpApi):
    """
    创建定向质押借贷
    """

    def __init__(self, currencyPairId, userId):
        super().__init__()
        self.url = f'{self.host}/api/prime/directPledgeLoan/add/'
        self.method = 'post'
        self.json = {"attachment": [],
                     "generalAgreementStatus": 1,  # 通用产品协议是否显示：0-不显示，1-显示
                     "currencyPairId": currencyPairId,  # 币对ID. 16064838851948 1704038400000
                     "loanAmount": "0.03",  # 借贷金额
                     "initialPledgeAmount": "26258.20568927",  # 币价
                     "pledgeAmount": "50000",  # 质押金额
                     "rate": "2.62%",  # 年华利率
                     "warningRateLine": "0.3",  # 预警线
                     "payoutRateLine": "0.7",  #
                     "showStatus": 1,  # 是否显示：0-不显示，1-显示
                     "userId": userId,  # 用户ID 19057325194688
                     "loanIntervalType": 1,  # 借贷期限类型：1 固定期 2 开放期限
                     "loanAnnualizedProfitRate": "0.1",  # 借款年化利率(%)
                     "initialPledgeRate": "0.05",  # 初始质押率(%)
                     "overdueDays": 2,  # 逾期天数
                     "labelZhTw": "中文标签",  # 中文标签
                     "labelEnUs": "英文标签5",  # 英文标签
                     "loanInterval": 100}  # 借贷期限

    # {
    #     "attachment": [],
    #     "generalAgreementStatus": 0,
    #     "currencyPairId": 17063494265682,
    #     "loanAmount": "1000",
    #     "initialPledgeAmount": "0.73444734",
    #     "pledgeAmount": "10",
    #     "rate": "4.4%",
    #     "warningRateLine": "0.7",
    #     "payoutRateLine": "0.8",
    #     "showStatus": 1,
    #     "userId": 13057984349260,
    #     "loanIntervalType": 1,
    #     "loanAnnualizedProfitRate": "0.1",
    #     "initialPledgeRate": "0.6",
    #     "overdueDays": 2,
    #     "labelZhTw": "",
    #     "labelEnUs": "",
    #     "loanInterval": 100
    # }
if __name__ == '__main__':
    print(random.randint(1, 10))
    print(fake.date_time_between_dates())
